# author ： 以凝
# time   ： 2024/3/21  16:08

from PyQt5.QtCore import QThread, pyqtSignal
import time

class PlayThread(QThread):
    update_request = pyqtSignal()  # 用于请求更新GUI的信号
    error = pyqtSignal(str)

    def __init__(self, interval=1):
        super().__init__()
        self.interval = interval
        self.play_mode = False

    def run(self):
        self.play_mode = True
        while self.play_mode:
            # 发出信号而不是直接调用open_next_image方法
            self.update_request.emit()
            time.sleep(self.interval)

    def stop(self):
        self.play_mode = False